using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using Marlimer.Common;

namespace Marlimer.Data.Comercial
{
    public class com_Ventas
    {
        public DataTable AvancesXSKU(DateTime dfec_ini, DateTime dfec_fin, int ccod_zona, int ccod_ruta,string ccods_grpvta)
        {
            SqlCommand sqlcmd = new SqlCommand();
            SqlDataAdapter da = new SqlDataAdapter();
            DataSet ds = new DataSet();

            sqlcmd.CommandText = "sprAvancesXSKU";
            sqlcmd.CommandType = CommandType.StoredProcedure;
            sqlcmd.Connection = Session.getConexion();

            sqlcmd.Parameters.Add("@dfec_ini", SqlDbType.DateTime);
            sqlcmd.Parameters.Add("@dfec_fin", SqlDbType.DateTime);
            sqlcmd.Parameters.Add("@ccod_zona", SqlDbType.Int);
            sqlcmd.Parameters.Add("@ccod_ruta", SqlDbType.Int);
            sqlcmd.Parameters.Add("@ccods_grpvta", SqlDbType.NVarChar, 255);

            sqlcmd.Parameters["@dfec_ini"].Value = dfec_ini;
            sqlcmd.Parameters["@dfec_fin"].Value = dfec_fin;
            sqlcmd.Parameters["@ccod_zona"].Value = ccod_zona;
            sqlcmd.Parameters["@ccod_ruta"].Value = ccod_ruta;
            sqlcmd.Parameters["@ccods_grpvta"].Value = ccods_grpvta;

            da.SelectCommand = sqlcmd;
            da.Fill(ds);

            return ds.Tables[0];
        }


        public DataTable DevolucionXMotivo(DateTime dfec_ini, DateTime dfec_fin, int ccod_zona, int ccod_ruta, string ccods_grpvta)
        {
            SqlCommand sqlcmd = new SqlCommand();
            SqlDataAdapter da = new SqlDataAdapter();
            DataSet ds = new DataSet();

            sqlcmd.CommandText = "sprDevolucionXMotivo";
            sqlcmd.CommandType = CommandType.StoredProcedure;
            sqlcmd.Connection = Session.getConexion();

            sqlcmd.Parameters.Add("@dfec_ini", SqlDbType.DateTime);
            sqlcmd.Parameters.Add("@dfec_fin", SqlDbType.DateTime);
            sqlcmd.Parameters.Add("@ccod_zona", SqlDbType.Int);
            sqlcmd.Parameters.Add("@ccod_ruta", SqlDbType.Int);
            sqlcmd.Parameters.Add("@ccods_grpvta", SqlDbType.NVarChar, 255);

            sqlcmd.Parameters["@dfec_ini"].Value = dfec_ini;
            sqlcmd.Parameters["@dfec_fin"].Value = dfec_fin;
            sqlcmd.Parameters["@ccod_zona"].Value = ccod_zona;
            sqlcmd.Parameters["@ccod_ruta"].Value = ccod_ruta;
            sqlcmd.Parameters["@ccods_grpvta"].Value = ccods_grpvta;

            da.SelectCommand = sqlcmd;
            da.Fill(ds);

            return ds.Tables[0];
        }
    }
}
